//
//  JiLuVC.m
//  HxgProject
//
//  Created by hxg on 2018/3/10.
//  Copyright © 2018年 XMYY-19. All rights reserved.
//

#import "JiLuVC.h"
#import "RDVTabBarController.h"

#import "JiLuTVCell.h"
#import "ApplyInfo.h"

@interface JiLuVC ()

@end

@implementation JiLuVC

- (void)viewWillDisappear:(BOOL)animated {
    [[self rdv_tabBarController] setTabBarHidden:NO animated:YES];
    
    [super viewWillDisappear:animated];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    [[self rdv_tabBarController] setTabBarHidden:YES animated:YES];
}

#pragma mark - custom

#pragma mark - system
- (void)viewDidLoad {
    [super viewDidLoad];
    
   // self.navigationItem.title = @"申请记录";
    
    //
    self.navigationItem.title = self.showTitleStr;
    self.tableView.tableFooterView = [[UIView alloc] init];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.detailApplyArr.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 110;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    // 定义唯一标识
    static NSString *CellIdentifier = @"JiLuTVCell";
    // 通过唯一标识创建cell实例
    JiLuTVCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    // 判断为空进行初始化  --（当拉动页面显示超过主页面内容的时候就会重用之前的cell，而不会再次初始化）
    if (!cell) {
        cell = [[JiLuTVCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    // 对cell 进行简单地数据配置
    ApplyInfo *applyInfo = self.detailApplyArr[indexPath.row];
    cell.serviceMoneyLbl.text = applyInfo.serviceNum;
    cell.applyZhouqiLbl.text = applyInfo.applyCycle;
    cell.curStateLbl.text = [self getStateStr:applyInfo.curState];
    cell.applyTimeLbl.text = applyInfo.applyTime;
    cell.applyNumLbl.text = applyInfo.applyNum;
       
    return cell;
}

- (NSString *)getStateStr:(NSString *)stateStr
{
    if ([stateStr isEqualToString:@"0"]) {
        return @"待放款";
    } else if ([stateStr isEqualToString:@"1"]) {
        return @"已放款";
    } else if ([stateStr isEqualToString:@"2"]) {
        return @"已还清";
    }
    
    return nil;
}



@end
